--该文件用来封装查找位置的方法

--查找区域内最合适投球的位置
function bestPositionForThrow()
	--sysLog("开始查找最合适的投球位置");
	
	local position = {};
	position.x = -1;
	position.y = -1;
	position.area = Bottom;
	position.color = YellowColor;
	

	--最下面的区域查找绿色的投球位置
	--sysLog("查找最下方区域，绿色篮筐");
	position = greenPositionInArea(Bottom);
	if position.x > -1 then
		return position;
	end

	--中间区域查找绿色的投球位置
	--sysLog("查找中间区域，绿色篮筐");
	position = greenPositionInArea(Middle);
	if position.x > -1 then
		return position;
	end

	--最下面的区域查找黄色的投球位置
	--sysLog("查找最下方区域，黄色篮筐");
	position = yellowPositionInArea(Bottom);
	if position.x > -1 then
		return position;
	end
	





	--[[
	--中间区域查找黄色的投球位置
	--sysLog("查找中间区域，黄色篮筐");
	position = yellowPositionInArea(Middle);
	if position.x > -1 then
		return position;
	end

--]]

	
	--sysLog("未找到有效的投球位置！！！");
	
end

--查找区域内绿色篮筐的位置
function greenPositionInArea(area)

	local position = {};
	position.area = area;
	position.x = -1;
	position.y = -1;
	position.color = GreenColor;
	
	if area == Middle then
		--sysLog("在middle区域中");
		position.x, position.y = findMultiColorInRegionFuzzy(0x53761e,"-14|-13|0xc9e47d,12|15|0xbddd6e,2|104|0x435f18,13|113|0xa2ce57", 98, MiddleRect[1],MiddleRect[2],MiddleRect[3],MiddleRect[4]);

	elseif area == Bottom then
		--sysLog("在bottom区域中");
		position.x, position.y = findMultiColorInRegionFuzzy(0x53761e,"0|81|0x466419,-12|101|0xa5d15a,-10|136|0x9bcc51,17|-20|0xc9e47d", 98, BottomRect[1],BottomRect[2],BottomRect[3],BottomRect[4]);

		
	end
	
	
	return position;
end

--查找区域内黄色篮筐的位置
function yellowPositionInArea(area)

	local position = {};
	position.area = area;
	position.x = -1;
	position.y = -1;
	position.color = YellowColor;
	
	if area == Middle then
		--sysLog("在middle区域中");
		position.x, position.y = findMultiColorInRegionFuzzy(0x754e1e,"-16|-19|0xe3ce7a,13|12|0xdec46e,3|95|0x603f18,13|96|0xd1b05a,44|110|0x004b91",98, MiddleRect[1],MiddleRect[2],MiddleRect[3],MiddleRect[4]);
		
	elseif area == Bottom then
		--sysLog("在bottom区域中");
		position.x, position.y = findMultiColorInRegionFuzzy(0x754e1e,"-15|19|0xdec46e,-14|74|0xd5b65f,18|-15|0xe4cf7c,5|4|0x754e1e", 98, BottomRect[1],BottomRect[2],BottomRect[3],BottomRect[4]);

	end
	

	return position;
end


--查找是否是再来一次页面
function playAgainButtonPosition ()


 return findMultiColorInRegionFuzzy(0xee9e34,"-219|-62|0xf1b13f,-218|70|0xeb8929,219|69|0xeb8929,221|-61|0xf1b13f,44|-1|0xffffff,-31|-5|0xffffff", 98, 382, 1584, 859, 1749);

end

--查找是否是开始游戏页面
function beginGameButtonPosition ()

	return findMultiColorInRegionFuzzy(0xdd520a,"-203|-29|0xfdfcfe,253|-20|0xfdfcfe,15|-90|0xfdfcfe,76|-17|0xdd520a,77|3|0xdd520a", 98, 381, 1944, 862, 2113);
end

